﻿using Sgr.Domain.Repositories;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;

namespace Sgr.DataCategories.Domain.DataCategoryItem
{
    /// <summary>
    /// 数据字典项仓储接口
    /// </summary>
    public interface IDataCategoryItemRepository : ITreeNodeBaseRepositoryOfTEntityAndTPrimaryKey<DataCategoryItem, long>
    {
        /// <summary>
        /// 检查特定类型下的数据字典值是否唯一
        /// </summary>
        /// <param name="value">字典项值</param>
        /// <param name="categoryTypeCode">字典分类编码</param>
        /// <param name="excludeId">需要排除的ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>是否已存在</returns>
        Task<bool> ValueIsUniqueInCategoryAsync(string value, string categoryTypeCode, long? excludeId = null, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据字典分类编码获取字典项列表
        /// </summary>
        /// <param name="categoryTypeCode">字典分类编码</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>字典项列表</returns>
        Task<IEnumerable<DataCategoryItem>> GetByCategoryTypeCodeAsync(string categoryTypeCode, CancellationToken cancellationToken = default);
    }
}